package com.hucheng.activity.entity;

import com.hucheng.activity.dto.LuckPrizeDTO;
import com.hucheng.activity.dto.UserPointDTO;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.sql.Timestamp;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-10
 * @Description: 持久层数据
 **/
@Data
public class UserPointDO {
    private Integer userPointId;
    private Integer userId;
    private Integer point;
    private Integer pointUsed;
    private Integer pointExpired;
    private Integer pointFrozen;
    private Integer isDel;
    private Timestamp dateCreated;
    private Timestamp dateUpdated;

    private Integer bePointExpired;


    public static UserPointDO buildUserPointDO(final UserPointDTO userPointDTO) {
        if (userPointDTO != null) {
            UserPointDO userPointDO = new UserPointDO();
            Timestamp currentTime = new Timestamp(System.currentTimeMillis());
            if (StringUtils.isNotEmpty(userPointDTO.getUserPointId()+"")) {
                userPointDO.setUserPointId(userPointDTO.getUserPointId());
                userPointDO.setDateCreated(currentTime);
            }else{
                userPointDO.setDateUpdated(currentTime);
            }
            userPointDO.setUserId(userPointDTO.getUserId());
            userPointDO.setPoint(userPointDTO.getPoint());
            userPointDO.setPointUsed(userPointDTO.getPointUsed());
            userPointDO.setPointExpired(userPointDTO.getPointExpired());
            userPointDO.setPointFrozen(userPointDTO.getPointFrozen());
            userPointDO.setIsDel(userPointDTO.getIsDel());
            return userPointDO;
        }
        return null;
    }
}
